home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
tn3270
/
addswt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-21
|
4KB
|
135 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.3d21, January 17, 1991
* Copyright (c) 1988, 1989, 1990, 1991 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistant Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include "maclib.h"
main(argc, argv)
int argc; char * argv[];
{
OSErr rc;
char * vname;
short vref, fref, sizeattrs;
long vsize, fsize;
Handle sizehandle;
struct {
short flags;
long prefsize;
long minsize;
} sizersc;
char fname[128];
char test;
if (argc < 2) {
printf("A fileid must be specified to addswt\n");
return;
}
strcpy(fname, argv[1]);
test = argc > 2;
/* get size of Mac3270 resource fork */
/* rc = GetVInfo(8, vname, &vref, &vsize);
if (rc != 0) {
printf("Error %d from GetVInfo.\n", rc);
return(rc);
} */
vref = 0;
rc = OpenRF(fname, vref, &fref);
if (rc != 0) {
printf("Error %d from OpenRF.\n", rc);
return(rc);
}
rc = GetEOF(fref, &fsize);
FSClose(fref);
if (rc != 0) {
printf("Error %d from GetEOF.\n", rc);
return(rc);
}
/* construct switcher resource to be added */
sizersc.flags = 0x5880;
sizersc.prefsize = (((fsize+102400L+1023L)/1024L) + 100) << 10;
sizersc.minsize = (((fsize+102400L+1023L)/1024L) + 61) << 10;
if (test) sizersc.prefsize += (270 << 10);
/* add new resource to Mac3270 */
fref = OpenResFile(fname);
rc = ResError();
if (rc != 0) {
printf("Error %d from OpenResFile.\n", rc);
return(rc);
}
sizehandle = NewHandle(10L);
memcpy(*sizehandle, &sizersc, 10);
AddResource(sizehandle, 'SIZE', -1, "Switcher/MF sizes");
rc = ResError();
if (rc != 0) {
printf("Error %d from AddResource.\n", rc);
CloseResFile(fref);
DisposHandle(sizehandle);
return(rc);
}
sizehandle = GetResource('SIZE', -1);
rc = ResError();
if (rc != 0) {
printf("Error %d from GetResource.\n", rc);
CloseResFile(fref);
DisposHandle(sizehandle);
return(rc);
}
sizeattrs = GetResAttrs(sizehandle);
rc = ResError();
if (rc != 0) {
printf("Error %d from GetResAttrs.\n", rc);
CloseResFile(fref);
DisposHandle(sizehandle);
return(rc);
}
sizeattrs |= resPreload;
SetResAttrs(sizehandle, sizeattrs);
rc = ResError();
if (rc != 0) {
printf("Error %d from SetResAttrs.\n", rc);
CloseResFile(fref);
DisposHandle(sizehandle);
return(rc);
}
CloseResFile(fref);
rc = ResError();
if (rc != 0) {
printf("Error %d from CloseResFile.\n", rc);
}
DisposHandle(sizehandle);
return(rc);
}